-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: prevent infinite loop in code_executor by preserving code execut… #3929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @YatindraRai002, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug that caused the code executor to fall into an infinite loop. The core problem stemmed from an incorrect classification of code execution events as 'empty' content, leading to their unintended exclusion from the LLM context. The solution involves refining the content filtering logic to explicitly preserve executable code and its results. This ensures that the agent's interaction history remains complete and prevents the loop. Comprehensive new tests have been added to verify the robustness of this fix and prevent regressions. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Hello @YatindraRai002, thank you for your contribution! Before we can review this PR, please address the following points from our contribution guidelines:
This information will help us to review your PR more efficiently. Thanks! Response from ADK Triaging Agent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses a potential infinite loop within the code executor by ensuring that code execution and result events are not incorrectly filtered out as empty. The core logic change in src/google/adk/flows/llm_flows/contents.py is sound and is well-supported by a new unit test. However, the newly added test script, test_code_executor_fix.py, contains a hardcoded absolute path, which is a critical issue that makes the test non-portable and needs to be resolved. Additionally, this new test script is placed at the root of the repository, which is unconventional; it would be better located within the tests directory to maintain project structure.
test_code_executor_fix.py
Outdated
| sys.path.insert(0, 'c:\\Users\\Asus\\Downloads\\adk-python\\src') | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code includes a hardcoded absolute path specific to a local machine. This will cause the script to fail for other developers and in any CI/CD environment. Please remove this path manipulation. The script should be run from an environment where the src directory is already included in the PYTHONPATH.
For example, you can run this script from the project's root directory with:
PYTHONPATH=src python test_code_executor_fix.py| @@ -0,0 +1,75 @@ | |||
| """Test to verify the code executor infinite loop fix.""" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ion events
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
If applicable, please follow the issue templates to provide as much detail as
possible.
Problem:
A clear and concise description of what the problem is.
Solution:
A clear and concise description of what you want to happen and why you choose
this solution.
Testing Plan
Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.
Unit Tests:
Please include a summary of passed
pytestresults.Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix.
Checklist
Additional context
Add any other context or screenshots about the feature request here.